package com.ebs.md.api.deal;

/**
 * Revision Author:
 *  $File: //depot/MarketData/commons-md-api/MAIN/src/main/java/com/ebs/md/api/deal/DealSideAction.java $
 *  $Revision: #1 $
 *  $DateTime: 2012/07/09 12:38:54 $
 *  $Change: 112297 $
 *  $Author: Arik.Sher $
 */


public enum DealSideAction
{
	 BUY
	,SELL
	;
	 
	public static DealSideAction getByName(String action) {
		if ( action == null ) {
			return null;
		}
		if ( "buy".equalsIgnoreCase(action) ) {
			return BUY;
		}
		if ( "sell".equalsIgnoreCase(action) ) {
			return SELL;
		}
		String actionLC = action.toLowerCase().trim();
		if ( actionLC.startsWith("sell") ) {
			return SELL;
		}
		if ( actionLC.startsWith("buy") ) {
			return BUY;
		}
		return null;
	}
	
	public static DealSideAction getByDealSide(boolean takerSold, DealSide thisDealSide) {
		if ( takerSold ) {
			if ( DealSide.TAKER.equals(thisDealSide) ) {
				return SELL;
			} else {
				return BUY;
			}
		} else {
			if ( DealSide.TAKER.equals(thisDealSide) ) {
				return BUY;
			} else {
				return SELL;
			}
		}
	}
	
}
